Turbo C Context File NODEE.RES NODEE.DEF NODEE.CPP NODCHILD.CPP NODDLGS.CPP ..\..\CLASS\CLASSWIN.CPP C:\W\A\LOCK.C C:\W\A\LOCK.DLL C:\W\A\LOCKDLL.C WMAIN.T WPROC.T A:NODEE2.CPP TO*.* A:*.* A:*.CPP NODCHILD.H *.CPP NoDWindow MainWindow wndclass lpfnWndProc lpszFile class szCleanFile NoDWindow *.DEF *.RES WMAIN2.H WMAIN2.CPP NODEE.DEF NODEE.RES *.CPP D:\PROGRAMS\CPP\NODDLGS.CPP D:\PROGRAMS\CPP\NODEE3.CPP D:\PROGRAMS\CPP\NODCHILD.CPP D:\PROGRAMS\CPP\NODDLGS.H D:\PROGRAMS\CPP\NODCHILD.H D:\PROGRAMS\CPP\NODEE3.CPP D:\PROGRAMS\CPP\NODDLGS.CPP D:\PROGRAMS\WIN\NODEE\NOD1.H D:\PROGRAMS\WIN\NODEE\NOCTRLD.DEF D:\PROGRAMS\WIN\CLASS\CLASSWIN.CPP D:\PROGRAMS\WIN\CLASS\CLASSWIN.H I wBytesWritten=_lwrite(hFile,lpszPostscript,lstrlen(lpszPostscript)); _lclose(hFile); MessageBox(hWnd,"File did not open", szClassName,MB_ICONEXCLAMATION|MB_OK); wBytesWritten=_lwrite(hFile,lpszPostscript,lstrlen(lpszPostscript)); _lclose(hFile); MessageBox(hWnd,"File did not open", szClassName,MB_ICONEXCLAMATION|MB_OK); int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow ) Main::hInstance = hInstance; Main::hPrevInstance = hPrevInstance; Main::lpszCommandLine = lpszCmdLine; Main::nCmdShow = nCmdShow; // A Windows class should be registered with Windows before any windows // of that type are created. // Register here all Windows classes that will be used in the program. // Windows classes should not be registered if an instance of // the program is already running. if ( ! Main::hPrevInstance ) { MainWindow::Register(); MainWindow MainWnd; return Main::MessageLoop(); class MainNoDee : public Main LPSTR DefDir; public: MainNoDee(); MainNoDee::MainNoDee (HANDLE a,HANDLE b,LPSTR c,int d) HANDLE Main::hInstance = a; HANDLE Main::hPrevInstance = 0; LPSTR Main::lpszCommandLine = '\0'; int Main::nCmdShow = 0; long FAR PASCAL _export WndProc ( HWND hWnd, WORD iMessage,WORD wParam, LONG lParam ); class Main public: static HANDLE hInstance; static HANDLE hPrevInstance; static LPSTR lpszCommandLine; static int nCmdShow; static int MessageLoop( void ); Main(HANDLE a,HANDLE b,LPSTR c,int d); HANDLE Main::hInstance = 0; HANDLE Main::hPrevInstance = 0; LPSTR Main::lpszCommandLine = '\0'; int Main::nCmdShow = 0; Main::Main(HANDLE a,HANDLE b,LPSTR c,int d) Main::hInstance = a; Main::hPrevInstance = b; Main::lpszCommandLine = c; Main::nCmdShow = d; int Main::MessageLoop( void ) MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) TranslateMessage( &msg ); DispatchMessage( &msg ); return msg.wParam; ifstream ini(o.szPathName); /* Upon the first WM_CREATE message, the handle hWnd is not yet valid. Do not use the handle until the CreateWindow call in the constructor has completed execution. Any code which need be executed on creation can be placed in the constructor. This differs from normal C programs. When CreateWindow sends the WM_CREATE message, the window handle is also passed to WndProc. Thereby, the first processing of WM_CREATE will have access to the handle. */ case WM_CREATE: /* Upon the first WM_CREATE message, the handle hWnd is not yet valid. Do not use the handle until the CreateWindow call in the constructor has completed execution. Any code which need be executed on creation can be placed in the constructor. This differs from normal C programs. When CreateWindow sends the WM_CREATE message, the window handle is also passed to WndProc. Thereby, the first processing of WM_CREATE will have access to the handle. */ /* All Dialog boxes derive from this class */ class Dialog protected: HWND hDlg; HWND hParent; public: Dialog(HWND a) {hParent=a}; HWND GetHandle(void) {return hDlg;} class AboutBox : public Dialog public: BOOL DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam); void AboutBox(HWND hParent):Dialog(hParent); void AboutBox::AboutBox(HWND hParent):Dialog(hParent); BOOL AboutBox::DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam) switch (message) case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: case IDCANCEL: EndDialog(hDlg,0); return TRUE; } break; return FALSE; /* All Dialog boxes derive from this class */ class Dialog protected: HWND hDlg; HWND hParent; public: Dialog(HWND a) {hParent=a}; HWND GetHandle(void) {return hDlg;} class AboutBox : public Dialog public: BOOL DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam); void AboutBox(HWND hParent):Dialog(hParent); void AboutBox::AboutBox(HWND hParent):Dialog(hParent); BOOL AboutBox::DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam) switch (message) case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: case IDCANCEL: EndDialog(hDlg,0); return TRUE; } break; return FALSE; (HWND hDlg,WORD message,WORD wParam,LONG lParam) pDialog->DlgProc(hDlg, iMessage, wParam, lParam ); // If data pointers are near pointers #if defined(__SMALL__) || defined(__MEDIUM__) inline Window *GetPointer( HWND hWnd ) return (Dialog *) GetWindowWord( hWnd, 2 ); inline void SetPointer( HWND hWnd, Window *pWindow ) SetWindowWord( hWnd, 2, (WORD) pDialog ); #elif defined(__LARGE__) || defined(__COMPACT__) inline Window *GetPointer( HWND hWnd ) return (Window *) GetWindowLong( hWnd, 4 ); inline void SetPointer( HWND hWnd, Window *pWindow ) SetWindowLong( hWnd, 4, (LONG) pDialog ); #else #error Choose another memory model! #endif /* All Dialog boxes derive from this class */ class Dialog DlgProc(hDlg, iMessage, wParam, lParam ) DialogBox (Main::hInstance,"AboutBox",hWnd,lpfnDlgProc); AboutBox A(hWnd,lpfnDlgProc); FARPROC lpfnDlgProc hParent=0; // If data pointers are near pointers #if defined(__SMALL__) || defined(__MEDIUM__) inline void SetDlgPointer( HWND hWnd, Dialog *pDialog ) SetWindowWord( hWnd, 2, (WORD) pDialog ); #elif defined(__LARGE__) || defined(__COMPACT__) inline void SetDlgPointer( HWND hWnd, Dialog *pDialog ) SetWindowLong( hWnd, 4, (LONG) pDialog ); #else #error Choose another memory model! #endif /* All dialog boxes are included from a separate file for convienence. An independent symbol table is used. */ // #include "dlg1.h" #include "dlg1.cpp" // the Main class #include "wmain2.h" // the Main class #include "wmain2.h" /*--------------------------------------------------- All dialog boxes are included from a separate file for convienence. An independent symbol table is used. */ // #include "dlg1.h" #include "dlg1.cpp" long FAR PASCAL _export WndProc ( HWND hWnd, WORD iMessage,WORD wParam, LONG lParam ); class AboutBox : public Dialog public: BOOL DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam); AboutBox(HWND hParent,FARPROC lprnDlgProc); AboutBox::AboutBox(HWND hParent,FARPROC lpfnDlgProc):Dialog(hParent) DialogBox (Main::hInstance,"AboutBox",hParent,lpfnDlgProc); BOOL AboutBox::DlgProc(HWND hDlg,WORD message,WORD wParam,LONG lParam) switch (message) case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: case IDCANCEL: EndDialog(hDlg,0); return TRUE; } break; return FALSE; MainNoD::szDefDir,MB_ICONEXCLAMATION|MB_OK); io.close(); MessageBox(hWnd,"File contains ^D", MainNoD::szDefDir,MB_ICONEXCLAMATION|MB_OK); MessageBox(hWnd,"File cleaned", MainNoD::szDefDir,MB_ICONEXCLAMATION|MB_OK); return 1; inline HANDLE WinBase::hWnd() return hWindow; inline ModalDialog::ModalDialog( HWND hOwner ) : result( 0 ) assert( curDlg == 0 ); curDlg = this; hWindow = hOwner; inline ModalDialog::~ModalDialog() assert( curDlg != 0 ); curDlg = 0; inline void Window::insert() nextWin = winList; winList = this; inline HANDLE WinBase::hWnd() return hWindow; inline void Window::insert() nextWin = winList; winList = this; //--------------------------------------------------------------------- // class SaveDir is only used locally, although it makes a handy // addition to a toolbox. When created it saves the current drive // and directory, and when destroyed it restores the drive and path // to the saved drive and directory. //--------------------------------------------------------------------- class SaveDir public: SaveDir(); ~SaveDir(); private: int drive; char path[MAXPATH]; SaveDir::SaveDir() drive = getdisk(); path[0] = '\\'; getcurdir( 0, path+1 ); SaveDir::~SaveDir() setdisk( drive ); chdir( path ); /* Member functions to be defined later Print a message in the client rectangle. */ long WndProc( WORD iMessage, WORD wParam, LONG lParam ); void Paint( void ); int Strip(LPSTR lpszFile); void Paint( void ); int Strip(LPSTR lpszFile); hMenu=LoadMenu(Main::hInstance,"MENU"); SetMenu(hWnd,hMenu); case IDM_OPT1A: Strip(Main::lpszCommandLine); return 0; case IDM_OPT1B: if (GetMenuState(hMenu,IDM_OPT1B,MF_BYCOMMAND)&&MF_CHECKED) CheckMenuItem(hMenu,IDM_OPT1B,MF_UNCHECKED); else CheckMenuItem(hMenu,IDM_OPT1B,MF_CHECKED); return 0; case IDM_H1A: WhoWroteBox x(hwnd); x.run(); return 0; case IDM_H1B: AboutBox p(hWnd); p.run(); return 0; default: MessageBeep(0); /* Define the members of NoDWindow */ char NoDWindow::szClassName[] = "No ^D !"; /*--------------------------------------------------------------------- class AboutBox draws and manages the About dialog. class AboutBox : public ModalDialog public: AboutBox( HWND ); private: virtual LPSTR getDialogName(); virtual BOOL dispatch( HWND, WORD, WORD, LONG ); LPSTR AboutBox::getDialogName() return "AboutBox"; BOOL AboutBox::dispatch( HWND hDlg, WORD msg, WORD wParam, LONG lParam ) switch( msg ) case WM_INITDIALOG: return TRUE; // no initialization. case WM_COMMAND: if( wParam == IDOK || wParam == IDCANCEL ) { EndDialog( hDlg, TRUE ); // selecting OK or Cancel return TRUE; // terminates the dialog } default: return ModalDialog::dispatch( hDlg, msg, wParam, lParam ); inline TodoWindow::TodoWindow() : fileName( 0 ) inline TodoWindow::~TodoWindow() inline AboutBox::AboutBox(HWND hOwner) : ModalDialog(hOwner) inline AboutBox::AboutBox(HWND hOwner) : ModalDialog(hOwner) inline WhoWroteBox::WhoWroteBox(HWND hOwner) : ModalDialog(hOwner) HANDLE WinBase::hInst = _hInstance; HANDLE WinBase::hPrevInst = _hPrev; LPSTR WinBase::cmd = _pszCmdline; int WinBase::show = _cmdShow; WhoWroteBox x(hWnd()); x.run(); hdc=GetDC(hWnd()); SelectObject(hdc,GetStockObject(SYSTEM_FONT)); GetTextMetrics(hdc,&tm); cxChar=tm.tmAveCharWidth; cyChar=tm.tmHeight+tm.tmExternalLeading; cxCaps=(tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar/2; ReleaseDC(hWnd(),hdc); BOOL NoDWindow::processMenuCommand(WORD wParam, long lParam) switch(wParam) case IDM_OPT1A: strip(WinBase::cmd); return TRUE; case IDM_OPT1B: if (GetMenuState(hMenu,IDM_OPT1B,MF_BYCOMMAND)&&MF_CHECKED) CheckMenuItem(hMenu,IDM_OPT1B,MF_UNCHECKED); else CheckMenuItem(hMenu,IDM_OPT1B,MF_CHECKED); return TRUE; case IDM_H1A: helpWroteBox(); return TRUE; case IDM_H1B: helpAboutBox(); return TRUE; default: MessageBeep(0); return FALSE; strip(WinBase::cmd); void paint( void ); int strip(LPSTR lpszFile); HWND hwndButton; HWND hParent; char *text="GO !" inline HANDLE GoButton::getHandle() return hwndButton; HDC hdc; TEXTMETRIC tm; int cxChar,cyChar; hParent=hA; hdc=GetDC(hParent); SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT)); GetTextMetrics(hdc,&tm); cxChar=tm.tmAveCharWidth; cyChar=tm.tmHeight+tm.tmExternalLeading; ReleaseDC(hParent,hdc); hwndChild=CreateWindow ("button",text,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 40*cxChar,10*cyChar, (len(text)+2)*cxChar,7*cyChar/4, hParent,MYCW_GOBUTTON,WinBase::hInst,NULL); HWND getHandle(void); HWND hwndChild; HWND hParent; inline HANDLE GoButton::getHandle() return hwndChild; int cx,cy; cx=GetSystemMetrics(SM_CXSCREEN); cy=GetSystemMetrics(SM_CYSCREEN); WS_DLGFRAME HDC hdc; TEXTMETRIC tm; int cxChar,cyChar; text="nothing yet"; hParent=hA; hdc=GetDC(hParent); SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT)); GetTextMetrics(hdc,&tm); cxChar=tm.tmAveCharWidth; cyChar=tm.tmHeight+tm.tmExternalLeading; ReleaseDC(hParent,hdc); hwndChild=CreateWindow ("static",text,WS_CHILDWINDOW|WS_VISIBLE|SS_LEFT, 10*cxChar,2*cyChar, (30+2)*cxChar,7*cyChar/4, hParent,MYCW_FIRSTLINE,WinBase::hInst,NULL); void FirstLine::create(HWND hA) void FirstLine::set(LPSTR a) SetWindowText(hwndChild,a); fl.set("Postscript"); fl.set(szBuffer); fl.set(szBuffer); getcwd(szFileName,MAXPATH); BOOL FileList::fileClick(void) int index; char szBuffer[MAXPATH]; OFSTRUCT ofs; if (LB_ERR == (index= (WORD) send(LB_GETCURSEL,0,0L)) ) return FALSE; send(LB_GETTEXT,index,(LONG) (char far *) szBuffer); if (-1 != OpenFile(szBuffer,&ofs,OF_EXIST|OF_READ)) bValidFile=TRUE; getcwd(szFileName,MAXPATH); if (szBuffer[strlen(szFileName)-1] != '\\') strcat(szFileName,"\\"); strcat(szFileName,szBuffer); else bValidFile=FALSE; szBuffer[strlen(szBuffer)-1] = '\0'; chdir(szBuffer+1); getcwd(szBuffer,MAXPATH); SetWindowText(hDirField,szBuffer); send(LB_RESETCONTENT,0,0L); send(LB_DIR,0x37,(LONG)(LPSTR) "*.*"); return TRUE; SendMessage(hDirList,LB_DIR,0xC010,(LONG)(LPSTR) "*.*"); if (bOneClick) CheckMenuItem(hMenu,IDM_OPT1B,MF_CHECKED); else CheckMenuItem(hMenu,IDM_OPT1B,MF_UNCHECKED); return TRUE; send(LB_RESETCONTENT,0,0L); send(LB_DIR,0x0,(LONG)(LPSTR) "*.*"); dbox.unset(); EnableWindow(gb.getHandle(),FALSE); SetFocus(hWnd()); if (test(lpszCleanFile)) { dbox.set(); EnableWindow(gb.getHandle(),TRUE); SetFocus(gb.getHandle()); } else { dbox.unset(); EnableWindow(gb.getHandle(),FALSE); SetFocus(hWnd()); } bValidFile=FALSE; szBuffer[strlen(szBuffer)-1] = '\0'; chdir(szBuffer+1); getcwd(szBuffer,MAXPATH); SetWindowText(hDirField,szBuffer); bValidFile=FALSE; if (test(lpszCleanFile)) { dbox.set(); EnableWindow(gb.getHandle(),TRUE); SetFocus(gb.getHandle()); } else { dbox.unset(); EnableWindow(gb.getHandle(),FALSE); SetFocus(hWnd()); } { dbox.set(); EnableWindow(gb.getHandle(),TRUE); SetFocus(gb.getHandle()); } { dbox.unset(); EnableWindow(gb.getHandle(),FALSE); SetFocus(hWnd()); } return TRUE; dbox.unset(); EnableWindow(gb.getHandle(),FALSE); SetFocus(hWnd()); bOneClick=!bOneClick; if (bOneClick) CheckMenuItem(hMenu,IDM_OPT1B,MF_CHECKED); else CheckMenuItem(hMenu,IDM_OPT1B,MF_UNCHECKED); if (bOneClick) CheckMenuItem(hMenu,IDM_OPT1B,MF_CHECKED); else CheckMenuItem(hMenu,IDM_OPT1B,MF_UNCHECKED); WritePrivateProfileString ("NoDee","OneClick",(int) OneClick,"nodee.ini"); if(bInstantStrip) WritePrivateProfileString ("NoDee","OneClick","True","nodee.ini"); else WritePrivateProfileString ("NoDee","OneClick","False","nodee.ini"); if (GetPrivateProfileInt ("NoDee","OneClick",1,"nodee.ini") == 0) bOneClick=FALSE; else bOneClick=TRUE; SetClassWord(hwnd(),GCW_HCURSOR, SetClassWord(hwnd(),GCW_HCURSOR,LoadCursor(hInst,"NODEE")); SetClassWord(hwnd(),GCW_HCURSOR,LoadCursor(NULL,IDC_ARROW)); (int) (szBuffer[2]) - 'a' send(LB_RESETCONTENT,0,0L); send(LB_DIR,0x0,(LONG)(LPSTR) "*.*"); SendMessage(hDirList,LB_RESETCONTENT,0,0L); SendMessage(hDirList,LB_DIR,0xc010,(LONG)(LPSTR) "*.*"); CheckMenuItem(hMenu,IDM_OPT1C,bUseFileMask ? MF_CHECKED:MF_UNCHECKED); childFileList.mask(bUseFileMask ? "*.ps" : "*.*" ); CheckMenuItem(hMenu,IDM_OPT1A,bInstantStrip ? MF_CHECKED:MF_UNCHECKED); childFileList.mask(bUseFileMask ? "*.ps" : "*.*" ); CheckMenuItem(hMenu,IDM_OPT1C,bUseFileMask ? MF_CHECKED:MF_UNCHECKED); char NoDWindow::szClassName[] = "No ^D !"; #pragma arsused SetWindowText(hDirField,szDirName); SetWindowText(hDirField,szDirName); SetClassWord (childFileList.FileList::getHandle(), GCW_HCURSOR, bInstantStrip ? LoadCursor(hInst,"NODEE"):LoadCursor(NULL,IDC_ARROW) ); SetClassWord (childFileList.FileList::getHandle(), GCW_HCURSOR, LoadCursor(NULL,IDC_ARROW) ); GetPrivateProfileString ("NoDee","Mask",szMask,MAXPATH,"nodee.ini") if (GetPrivateProfileString ("NoDee","DefDir","",szDefDir,MAXPATH,"nodee.ini") != 0 ) WinHelp(hWindow,HELPFILE,HELP_INDEX,NULL); hPoint=LoadBitmap(WinBase::hInst,"D1"); hDC=GetDC(hWindow); hdcMem=CreateCompatibleDC(hDC); SelectObject(hdcMem,hPoint); SetMapMode(hdcMem,GetMapMode(hDC)); GetObject(hPoint,sizeof(BITMAP),(LPSTR) &bm); ptSize.x=bm.bmWidth; ptSize.y=bm.bmHeight; DPtoLP(hdc,&ptSize,1); ptOrg.x=cxClient-ptSize.x ptOrg.y=0; DPtoLP(hdcMem,&ptOrg,1); BitBlt(hdc,xStart,yStart,ptSize.x,ptSize.y, hdcMem,ptOrg.x,ptOrg.y,SRCCOPY); Delete (hdcMem); ReleaseDC(hWindow,hDC); cxClient-ptSize.x cxClient-ptSize.x hPoint=LoadBitmap(WinBase::hInst,"D5"); hPoint=LoadBitmap(WinBase::hInst,"D5"); SelectObject(hdcMem,hPoint); SetMapMode(hdcMem,GetMapMode(hDC)); GetObject(hPoint,sizeof(BITMAP),(LPSTR) &bm); ptSize.x=bm.bmWidth; ptSize.y=bm.bmHeight; DPtoLP(hDC,&ptSize,1); ptOrg.x=0; ptOrg.y=0; DPtoLP(hdcMem,&ptOrg,1); BitBlt(hDC,cxClient-ptSize.x,0,ptSize.x,ptSize.y, hdcMem,ptOrg.x,ptOrg.y,SRCCOPY); hPoint=LoadBitmap(WinBase::hInst,"D4"); SelectObject(hdcMem,hPoint); SetMapMode(hdcMem,GetMapMode(hDC)); GetObject(hPoint,sizeof(BITMAP),(LPSTR) &bm); ptSize.x=bm.bmWidth; ptSize.y=bm.bmHeight; DPtoLP(hDC,&ptSize,1); ptOrg.x=0; ptOrg.y=0; DPtoLP(hdcMem,&ptOrg,1); BitBlt(hDC,cxClient-ptSize.x,0,ptSize.x,ptSize.y, hdcMem,ptOrg.x,ptOrg.y,SRCCOPY); Copyright (c) 1991 by Borland International All Rights Reserved.